package com.mindskip.xzs.controller.wx.student;

import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.service.QywxAuthService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;


@Controller("QywxAuthController")
@RequestMapping(value = "/inApi/qywx/student/auth")
@ResponseBody
public class QywxAuthController {

    @Resource
    private QywxAuthService qywxAuthService;

    /**
     * 企业小程序授权登录
     *
     * @param code code只有5分钟时效，且只能使用一次
     */
    @GetMapping("/appletLogin")
    public RestResponse<HashMap<String, Object>> appletLogin(@RequestParam("code") String code) {
        return RestResponse.ok(qywxAuthService.appletLogin(code));
    }

}
